// 49.字母异位词分组

package LeetcodeHot100;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Solution049 {
    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String, List<String>> map = new HashMap<>();
        for (String s : strs) {
            char[] charArray = s.toCharArray();
            Arrays.sort(charArray);
            String string = String.valueOf(charArray);
            if (!map.containsKey(string))
                map.put(string, new ArrayList<String>());
            map.get(string).add(s);
        }
        List<List<String>> result = new ArrayList<>();
        for (String keySet : map.keySet()) {
            result.add(map.get(keySet));
        }
        return result;
    }

    public static void main(String[] args) {
        String s = "a";
        String a = "a";
        System.out.println(s.equals(a));
    }
}
